package com.heima.user.controller.v1;

import com.heima.common.constants.UserAuthConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserCheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: Tangguo
 * @Date: 2023-06-20  21:47
 */
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserCheckController {

   @Autowired
   private ApUserCheckService apUserCheckService;

   /**
    * 查询用户列表
    * @param dto:
    * @return ResponseResult
    */
   @PostMapping("/list")
   public ResponseResult list(@RequestBody AuthDto dto){
      return apUserCheckService.loadUserList(dto);
   }


   /**
    * 用户审核失败
    * @param dto:
    * @return ResponseResult
    */
   @PostMapping("/authFail")
   public ResponseResult authFail(@RequestBody AuthDto dto){
      return apUserCheckService.authWithUpdateStatus(dto, UserAuthConstants.AUTH_FAIL);
   }



   /**
    * 用户审核成功
    * @param dto:
    * @return ResponseResult
    */
   @PostMapping("/authPass")
   public ResponseResult authPass(@RequestBody AuthDto dto ){
      return apUserCheckService.authWithUpdateStatus(dto, UserAuthConstants.AUTH_PASS);
   }





}
